package com.andy.dao.impl;

import com.andy.dao.TransferDao;
import com.andy.dao.entity.TAccount;
import com.andy.infrastructure.ioc.annotation.Autowire;
import com.andy.infrastructure.ioc.annotation.Component;
import com.andy.infrastructure.ioc.annotation.Repository;
import com.andy.infrastructure.util.CurrentThreadConnectionManager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * mock的一个dao实现类
 * Component注解放入了自定义的name
 */
@Component(name = "transferMockDao")
public class TransferMockDaoImpl implements TransferDao {

    @Autowire
    private CurrentThreadConnectionManager currentThreadConnectionManager;

    /**
     * 卡号查询账户对象
     *
     * @param cardNo
     * @return
     * @throws Exception
     */
    @Override
    public TAccount queryAccountByCardNo(String cardNo) throws Exception {
        System.out.println("模拟查询了数据库");

        TAccount account = new TAccount();
        account.setId(1);
        account.setCardNo("123321");
        account.setBalanceAmount(9000d);

        return account;
    }

    /**
     * 修改单个账户余额
     * @param account
     * @throws Exception
     */
    @Override
    public int updateCustBalanceAmount(TAccount account) throws Exception {
        System.out.println("模拟修改了数据库");

        return 1;
    }
}
